package com.chen.fegin;

import com.chen.config.auth.OAuth2FeignConfig;
import com.chen.dto.AccountDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;
import java.util.List;

/**
 * @Author: chen
 * @Date: 2021/5/18 3:25 PM
 * @Version 1.0
 */
@FeignClient(value = "finance-server",
        configuration = OAuth2FeignConfig.class,
        path = "/account",
        contextId = "account")
public interface AccountFegin {

    /**
     * 根据用户id 和币种id来获取用户的账户余额
     * @param coinId
     * @param userId
     * @return
     */
    @GetMapping("/getUserAccountByCoinId")
    AccountDto getUserAccountByCoinId(@RequestParam("coinId") Long coinId,
                                      @RequestParam("userId") Long userId);

    /**
     * 将用户自己的可用余额  -》 冻结余额
     * @param coinId 币种id
     * @param userId 用户id
     * @param amount 转入数量
     * @param orderId 来源的订单
     * @return
     */
    @GetMapping("/transferUserLock")
    Boolean transferUserLock(@RequestParam("coinId") Long coinId,
                             @RequestParam("userId") Long userId,
                             @RequestParam("amount") BigDecimal amount,
                             @RequestParam("orderId") Long orderId);

    @GetMapping("/buildUserAccount")
    List<AccountDto> buildUserAccount(@RequestParam("userId") Long userId);
}
